<?php
/*
Template Name: Ajax Post
*/
?>
<?php
	$post = get_post($_GET['id']);
	$args = array(
		'status' => 'approve',
		'number' => '5',
		'post_id' => $post->ID, 
	);	
	$comments = get_comments($args);
	
	// customized comment form
	$fields =  array(
	'author' => '<input id="author"  type="text" placeholder="Your Name" name="author">'.( $req ? '<span class="required">*</span>' : '' ),
	'email'  => '<input id="email" type="text" placeholder="Your Email" name="email">'. ( $req ? '<span class="required">*</span>' : '' ), 
	'url'    => '',
	'redirect'=>"<input type='hidden' name='redirect_to' value=bloginfo('url') />",
	);
	$comment_submit = array(
		'title_reply'          => __( 'Leave a comment' ),
		'comment_notes_before' => '',
		'comment_notes_after' => '',
		'comment_field' =>'<textarea id="comment" name="comment" placeholder="Write Some Comment..."></textarea>',
		'id_submit' => 'submit-btn',
		'fields'=> apply_filters( 'comment_form_default_fields', $fields ),
	);	
?>
<?php if ($post) : ?>
	<?php setup_postdata($post); ?>
		<a class="detail-size detail-expend" href="#"></a>
		<a id="detail-close" href="#"></a>
		<div class="idea-title"><h1><?php echo $post->post_title;?></h1></div>
			
			<div class="idea-content">
			<?php echo $post->post_content;?>	
			</div>
			
			<div class="idea-tag">
				<a href="#" class="tag-btn"><span>tag</span></a>
				<a href="#" class="tag-btn"><span>long long tag</span></a>
				<div style="clear: both;"></div>
			</div>
			
			<div class="idea-author">
				<?php echo get_avatar($post->post_author, $size = '47' ); ?>
				<div class="author-info">
					<span class="author-name"><?php the_author($post->ID); ?></span><br>
					<?php if (get_the_author_meta( 'user_url' , $post->post_author)): ?>
						<span><a href="<?php the_author_meta( 'user_url' , $post->post_author ); ?>"><?php the_author_meta( 'user_url' , $post->post_author ); ?></a></span><br>
					<?php endif; ?>
					<?php if (get_the_author_meta( 'user_email' , $post->post_author)): ?>
						<span><a href="mailto:<?php the_author_meta( 'user_email' , $post->post_author ); ?>"><?php the_author_meta( 'user_email' , $post->post_author ); ?></a></span>
					<?php endif; ?>
				</div>
				<div style="clear: both;"></div>
			</div>
									
			<div class="idea-post-date">									
				<span>Last modified on May <?php echo $post->post_modified ; ?></span>
				<div style="clear: both;"></div>
			</div>
			
			<hr />
			<?php comment_form($comment_submit); ?>
			
			<!--								
			<div class="comment-box">									
				<h1>Leave a comment</h1>
					<input type="text" placeholder="Your Name" name="user-name">
					<input type="text" placeholder="Your Email" name="user-email">
					<textarea placeholder="Write Some Comment..." name="comment-text"></textarea>
					<input type="submit" class="submit-btn" value="Post Comment" name="submit">
					<div style="clear: both;"></div>
			</div>
			-->
			<?php if ($comments): ?>
				<hr/>
				<div class="comment-title"><h1>Comments</h1></div>
				<div class="comment-list">
				<?php foreach($comments as $comment) :?>
				<div  id="comment-<?php comment_ID();?>" class="comment-item" >
					<div class="comment-author">									
						<?php echo get_avatar($comment->user_id, $size = '47' ); ?>
						<div class="author-info">
							<span class="author-name"><?php echo $comment -> comment_author ?></span><br>
							<span class="comment-date"><?php echo $comment -> comment_date ?></span>
						</div>
						<div style="clear: both;"></div>
					</div>
					<div class="comment-content">
						<?php echo $comment -> comment_content ?>
					</div>
				</div>
				<?php endforeach; ?>
				</div>
			<?php endif; ?>
					
<?php endif; ?>